#import "AppDelegate.h"
//#import "UIViewControllerDemo.h"
#import "PlatformRouterImp.h"
//#import "NativeViewController.h"
#import "GeneratedPluginRegistrant.h"


@implementation AppDelegate

- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [GeneratedPluginRegistrant registerWithRegistry:self];
    
    PlatformRouterImp *router = [PlatformRouterImp new];
    [FlutterBoostPlugin.sharedInstance startFlutterWithPlatform:router
                                                        onStart:^(FlutterEngine *engine) {
        
        // 注册MethodChannel，监听flutter侧的getPlatformVersion调用
        FlutterMethodChannel *flutterMethodChannel = [FlutterMethodChannel methodChannelWithName:@"flutter_native_channel" binaryMessenger:engine.binaryMessenger];
        
        [flutterMethodChannel setMethodCallHandler:^(FlutterMethodCall * _Nonnull call, FlutterResult  _Nonnull result) {
            
            NSString *method = call.method;
            if ([method isEqualToString:@"getPlatformVersion"]) {
                NSString *sysVersion = [[UIDevice currentDevice] systemVersion];
                result(sysVersion);
            } else {
                result(FlutterMethodNotImplemented);
            }
            
        }];
    }];
    
    self.window = [[UIWindow alloc] initWithFrame: [UIScreen mainScreen].bounds];


    [self.window makeKeyAndVisible];
    
    FLBFlutterViewContainer *fvc = FLBFlutterViewContainer.new;
 
    UINavigationController *rvc = [[UINavigationController alloc] initWithRootViewController:fvc];
    //隐藏bar,用flutter的bar
    [rvc setNavigationBarHidden:YES animated:YES];
    //用来控制flutter跳转iOS
    router.navigationController = rvc;
    
    self.window.rootViewController = rvc;
    
    // Override point for customization after application launch.
    return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

@end
